﻿//==============================================================================  
//Copyright (C) 2012-2015 9UN.ORG. All rights reserved. 
//GUID：8e418a47-2d5d-4fb1-a376-2a17ab663069
//CLR Version: 4.0.30319.18033
//Code Author：Kevin Wang
//Contact：Email(Admin@9un.org),QQ(265382 or 74344)
//Filename：VideoTools
//Namespace：RuanRang.Media.Core.Common
//Functions：VideoTools  
//Created by Kevin Wang at 2013/3/3 15:08:14 http://blog.9un.org
//============================================================================== 
using System;
using RuanRang.Media.Core.Internal.DataStructures;
using RuanRang.Media.Core.Internal.Interop;

namespace RuanRang.Media.Core.Common
{
    public class VideoTools
    {
        /// <summary>
        /// Gets the video adjust.
        /// </summary>
        /// <param name="internalPlayerDescriptor">The internal player descriptor.</param>
        /// <param name="option">The option.</param>
        /// <returns>System.Object.</returns>
        public static object GetVideoAdjust(IntPtr internalPlayerDescriptor, VideoAdjustOption option)
        {
            object result = -1;
            switch (option)
            {
                case VideoAdjustOption.Brightness:
                    //亮度
                    result = LibVlcVideoInterop.libvlc_video_get_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Brightness);
                    break;
                case VideoAdjustOption.Contrast:
                    //对比度度
                    result = LibVlcVideoInterop.libvlc_video_get_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Contrast);
                    break;
                case VideoAdjustOption.Enable:
                    //启用视频画面调整
                    result = LibVlcVideoInterop.libvlc_video_get_adjust_int(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Enable);
                    break;
                case VideoAdjustOption.Gamma:
                    //调整伽马
                    result = LibVlcVideoInterop.libvlc_video_get_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Gamma);
                    break;
                case VideoAdjustOption.Hue:
                    //调整色调
                    result = LibVlcVideoInterop.libvlc_video_get_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Hue);
                    break;
                case VideoAdjustOption.Saturation:
                    //调整饱和度
                    result = LibVlcVideoInterop.libvlc_video_get_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Saturation);
                    break;
            }
            return result;
        }

        /// <summary>
        /// Videos the adjust.
        /// </summary>
        /// <param name="internalPlayerDescriptor">The internal player descriptor.</param>
        /// <param name="option">The option.</param>
        /// <param name="value">The value.</param>
        public static void SetVideoAdjust(IntPtr internalPlayerDescriptor, VideoAdjustOption option, object value)
        {
            switch (option)
            {
                case VideoAdjustOption.Brightness:
                    //亮度
                    //默认1.0f
                    LibVlcVideoInterop.libvlc_video_set_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Brightness, (float)value);
                    break;
                case VideoAdjustOption.Contrast:
                    //对比度度
                    //默认1.0f
                    LibVlcVideoInterop.libvlc_video_set_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Contrast, (float)value);
                    break;
                case VideoAdjustOption.Enable:
                    //启用视频画面调整
                    LibVlcVideoInterop.libvlc_video_set_adjust_int(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Enable, (int)value);
                    break;
                case VideoAdjustOption.Gamma:
                    //调整伽马
                    //默认1.0f
                    LibVlcVideoInterop.libvlc_video_set_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Gamma, (float)value);
                    break;
                case VideoAdjustOption.Hue:
                    //调整色调
                    ////默认0.0f
                    LibVlcVideoInterop.libvlc_video_set_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Hue, (float)value);
                    break;
                case VideoAdjustOption.Saturation:
                    //调整饱和度
                    ////默认1.0f
                    LibVlcVideoInterop.libvlc_video_set_adjust_float(internalPlayerDescriptor, libvlc_video_adjust_option_t.libvlc_adjust_Saturation, (float)value);
                    break;
            }
        }
    }
}
